Update Gui.js
[bcp.git] / csptest / autoupdate gui.min.js By Epic0001
bloba4485b784b1898289a132b99597eea91556ba0b2
1 javascript:function getImgText(t){return new Promise((e=>{let n=new Image;n.src=t+"?"+Date.now(),n.crossOrigin="Anonymous",n.onload=function(){const t=document.createElement("canvas").getContext("2d");t.drawImage(n,0,0,this.width,this.height);let{data:r}=t.getImageData(0,0,this.width,this.height),i="",s=0;for(;s<r.length;)i+=String.fromCharCode(r[s%4==3?(s++,s++):s++]+256*r[s%4==3?(s++,s++):s++]);e(i)},n.onerror=n.onabort=()=>{n.onerror=n.onabort=null,document.querySelector("iframe").contentWindow.alert("It seems the GitHub is either blocked or down."),e("ERROR!")}}))}let i=document.querySelector("iframe");i||(document.createElement("iframe"),document.body.append(i),i.style.display="none");const alert=i.contentWindow.alert.bind(window),confirm=i.contentWindow.confirm.bind(window),prompt=i.contentWindow.prompt.bind(window),log=i.contentWindow.console.log;if("function call() { [native code] }"==window.fetch.call.toString()){const t=window.fetch.call;window.fetch.call=function(){return arguments[1].includes("s.blooket.com/rc")?log("Bypassed anti-cheat"):t.apply(this,arguments)}}const nil=Symbol("null"),This=Symbol("this"),Types={},tokens="NumberExpr:number_expr,FloatExpr:float_expr,StringExpr:string_expr,SymbolExpr:symbol_expr,BinaryExpr:binary_expr,PrefixExpr:prefix_expr,SuffixExpr:suffix_expr,AssignmentExpr:assignment_expr,ObjectExpr:object_expr,ArrayExpr:array_expr,CallExpr:call_expr,MemberExpr:member_expr,DynamicMemberExpr:dynamic_member_expr,TernaryExpr:ternary_expr,FuncExpr:func_expr,GroupExpr:group_expr,BlockStmt:block_stmt,ExpressionStmt:expression_stmt,VarDeclStmt:declr_stmt,FuncDeclStmt:func_decl_stmt,WhileStmt:while_stmt,ForStmt:for_stmt,IfStmt:if_stmt,ElseStmt:else_stmt,ReturnStmt:return_stmt,ContinueStmt:continue_stmt,BreakStmt:break_stmt,EndFunc:end_func,EndFor:end_for,EndWhile:end_while,EndIf:end_if,EndElse:end_else,TernaryQue:ternary_que,TernaryCol:ternary_col,EndTernary:end_ternary,ForIncr:for_incr,TypeofExpr:typeof_expr".split(",").map((t=>t.trim().split(":")));for(let t=0;t<tokens.length;t++)Types[tokens[t][0]]=tokens[t][1],Types[tokens[t][1]]=t,Types[t]=tokens[t][0];class Env{constructor(t,e={}){this.parent=t,this.constants=Object.create(null),this.variables=Object.create(null);for(const t in e)this.declareVar(t,e[t],!0)}declareVar(t,e,n){if(t in this.variables)throw new Error(`Cannot declare variable ${t}. As it already is defined.`);return n&&(this.constants[t]=!0),this.variables[t]=e}assignVar(t,e){if(this.constants[t])throw new Error("Cannot reassign constant variable");return this.resolve(t).variables[t]=e}hasVar(t){return t in this.variables||null!=this.parent&&this.parent.hasVar(t)}resolve(t){if(t in this.variables)return this;if(null==this.parent)throw new Error(`Cannot resolve '${t}' as it does not exist.`);return this.parent.resolve(t)}lookupVar(t){return this.resolve(t).variables[t]}}function assignment_op(t,e,n){switch(e){case"+=":return t+n;case"-=":return t-n;case"*=":return t*n;case"/=":return t/n;case"%=":return t%n;case"=":return n}throw new Error(`Unknown assignment operator: ${e}`)}class Eval{ind=0;source;constructor(t){this.source=t}StringExpr(){const t=this.source.charCodeAt(this.ind++),e=this.source.slice(this.ind,this.ind+t);return this.ind+=t,e}NumberExpr(){const t=this.source.charCodeAt(this.ind++);let e=0;for(let n=0;n<t;n++)e+=this.source.charCodeAt(this.ind++)*Math.pow(65536,n);return e}FloatExpr(){const t=this.source.charCodeAt(this.ind++),e=this.source.slice(this.ind,this.ind+t);return this.ind+=t,parseFloat(e)}SymbolExpr(t){const e=this.source.charCodeAt(this.ind++),n=this.source.slice(this.ind,this.ind+e);return this.ind+=e,t.lookupVar(n)}BlockStmt(t){const e=this.source.charCodeAt(this.ind++);for(let n=0;n<e;n++)this.evaluate(t)}VarDeclStmt(t){const e=this.evaluate(t),n=1==this.source.charCodeAt(this.ind++),r=1==this.source.charCodeAt(this.ind++)?this.evaluate(t):null;return t.declareVar(e,r,n)}ExpressionStmt(t){return this.evaluate(t)}MemberExpr(t){const e=this.evaluate(t),n=this.evaluate(t);let r=e?.[n];try{r&&(r[This]=e)}catch{}return r}AssignmentExpr(t){const e=Types[this.source.charCodeAt(this.ind++)];if("MemberExpr"==e){let e=this.evaluate(t);const n=this.evaluate(t);return e[n]=assignment_op(e[n],this.evaluate(t),this.evaluate(t))}if("SymbolExpr"==e){const e=this.source.charCodeAt(this.ind++),n=this.source.slice(this.ind,this.ind+e);return this.ind+=e,t.assignVar(n,assignment_op(t.lookupVar(n),this.evaluate(t),this.evaluate(t)))}throw new Error(`Unknown assignment type ${e}`)}PrefixExpr(t){const e=this.evaluate(t);switch(e){case"-":return-this.evaluate(t);case"!":return!this.evaluate(t)}throw new Error(`Unknown prefix operator: ${e}`)}ObjectExpr(t){const e={},n=this.source.charCodeAt(this.ind++);for(let r=0;r<n;r++){e[this.evaluate(t)]=this.evaluate(t)}return e}static LoopEnv(t){const e=new Env(t);return e.declareVar("break",nil),e.declareVar("continue",nil),e}ForStmt(t){const e=Eval.LoopEnv(t);this.evaluate(e);const n={...e.variables},r=this.ind,i=this.findNext(Types.for_stmt,Types.end_for),s=this.findNext(Types.for_stmt,Types.for_incr);for(;this.ind=r,this.evaluate(e)&&(this.evaluate(e),e.assignVar("continue",nil),e.lookupVar("break")==nil);){this.ind=s,this.evaluate(e);for(const t in e.variables)t in n||(delete e.variables[t],delete e.constants[t])}this.ind=i}WhileStmt(t){let e=Eval.LoopEnv(t);const n=this.ind,r=this.findNext(Types.while_stmt,Types.end_while);for(;this.ind=n,this.evaluate(e)&&(this.evaluate(e),e.assignVar("continue",nil),e.lookupVar("break")==nil);)e.variables={break:nil,continue:nil},e.constants=Object.create(null);this.ind=r}BinaryExpr(t){const e=this.evaluate(t),n=this.evaluate(t),r=this.evaluate(t);switch(n){case"+":return e+r;case"-":return e-r;case"*":return e*r;case"/":return e/r;case"%":return e%r;case"<":return e<r;case">":return e>r;case"<=":return e<=r;case">=":return e>=r;case"==":return e==r;case"!=":return e!=r;case"||":return e||r;case"&&":return e&&r}throw new Error(`Unknown binary operator ${n}`)}SuffixExpr(t){if(this.source.charCodeAt(this.ind++)==Types.symbol_expr){const e=this.StringExpr(t),n=this.evaluate(t);switch(n){case"++":return t.assignVar(e,t.lookupVar(e)+1);case"--":return t.assignVar(e,t.lookupVar(e)-1)}throw new Error(`Unknown suffix operator: ${n}`)}const e=this.evaluate(t),n=this.evaluate(t),r=this.evaluate(t);switch(r){case"++":return e[n]++;case"--":return e[n]--}throw new Error(`Unknown suffix operator: ${r}`)}CallExpr(t){const e=this.evaluate(t),n=[],r=this.source.charCodeAt(this.ind++);for(let e=0;e<r;e++)n.push(this.evaluate(t));if("function"==typeof e){let t;try{t=e.apply(e[This],n)}catch{}return t}}FuncExpr(t){this.ind++;const e=this.StringExpr(t),n=[],r=this.source.charCodeAt(this.ind++);for(let e=0;e<r;e++)this.ind++,n.push(this.StringExpr(t));const i=this.ind;this.ind=this.findNext(Types.func_expr,Types.end_func);const s=(...e)=>{const r=new Env(t);for(const t in n)r.declareVar(n[t],e[t]);return r.declareVar("return",nil),this.evaluateInd(r,i),r.lookupVar("return")};return e.length&&t.declareVar(e,s),s}ArrayExpr(t){const e=[],n=this.source.charCodeAt(this.ind++);for(let r=0;r<n;r++)e.push(this.evaluate(t));return e}ReturnStmt(t){const e=1==this.source.charCodeAt(this.ind++)?this.evaluate(t):null;return t.assignVar("return",e)}BreakStmt(t){return t.assignVar("break",!0)}ContinueStmt(t){return t.assignVar("continue",!0)}IfStmt(t){const e=this.findNext(Types.if_stmt,Types.end_if);this.evaluate(t)?(this.evaluate(new Env(t)),this.ind++,1==this.source.charCodeAt(this.ind++)&&(this.ind=this.findNext(Types.else_stmt,Types.end_else))):(this.ind=e,1==this.source.charCodeAt(this.ind++)&&(this.ind++,this.evaluate(new Env(t)),this.ind++))}TernaryExpr(t){const e=this.evaluate(t);this.ind++;const n=this.findNext(Types.ternary_expr,Types.end_ternary),r=this.findNext(Types.ternary_que,Types.ternary_col);let i;return e?(i=this.evaluate(t),this.ind=n):(this.ind=r,i=this.evaluate(t),this.ind++),i}GroupExpr(t){let e;const n=this.source.charCodeAt(this.ind++);for(let r=0;r<n;r++)e=this.evaluate(t);return e}TypeofExpr(t){return typeof this.evaluate(t)}findNext(t,e){let n,r=1;for(n=this.ind+1;n<this.source.length&&r>0;n++)2==this.source.charCodeAt(n-1)&&n++,this.source.charCodeAt(n)==e?r--:this.source.charCodeAt(n)==t&&r++;return n}curCode(){return this.source.charCodeAt(this.ind)}evaluate(t){const e=Types[this.source.charCodeAt(this.ind++)];if(!(t.hasVar("return")&&t.lookupVar("return")!=nil||t.hasVar("break")&&t.lookupVar("break")!=nil||t.hasVar("continue")&&t.lookupVar("continue")!=nil)){if(e in this)return this[e](t);throw console.error(new Error(`No eval function for type ${e}`)),new Error(`No eval function for type ${e}`)}}evaluateInd(t,e){const n=this.ind;this.ind=e;const r=this.evaluate(t),i=this.ind;return this.ind=n,[r,i]}}function addProps(t,e){for(const n in e)"object"==typeof e[n]?addProps(t[n],e[n]):t[n]=e[n]}const constants={true:!0,false:!1,null:null,setVal:(t,e)=>constants.stateNode.props.liveGameController.setVal({path:t,val:e}),print:log,console:i.contentWindow.console,window:window,alert:alert,confirm:confirm,prompt:prompt,promptFloat:t=>parseFloat(prompt(t)),promptNum:t=>parseInt(prompt(t)),Object:Object,Array:Array,Math:Math,queryElement:document.querySelector.bind(document),elStateNode:t=>Object.values(document.querySelector(t))[1].children._owner.stateNode,isNaN:isNaN,parseFloat:parseFloat,queryElementAll:document.querySelectorAll.bind(document),createElement:function(t,e,...n){const r=document.createElement(t);addProps(r,e);for(const t of n)r.append(t);return r}},env=new Env(void 0,constants);function runcode(t){new Eval(t).evaluate(new Env(env))}async function runcheat(){runcode(await getImgText("https://raw.githubusercontent.com/DannyDan0167/Blooket-Cheats-Plus/main/csptest/out/"+document.querySelector("#options").value+".png?"))}async function getCheats(){return JSON.parse((await getImgText("https://raw.githubusercontent.com/DannyDan0167/Blooket-Cheats-Plus/main/csptest/out/cheats.png?"+Date.now())).split("\0")[0])}const blookScriptGUI=document.createElement("div");blookScriptGUI.id="blookScriptGUI",blookScriptGUI.innerHTML='\n    <div id="blookScriptHeader">Blooket Script GUI by epic0001, Runtime by Jod, Scripts by Ducklife3141</div>\n    <div id="blookScriptContent">\n        <label for="options">Select an option:</label><br>\n        <select id="options">\n        <option>Loading scripts...</option>\n        </select><br>\n        <button id="ch">Run Cheat</button>\n     \n    </div>\n';const guiStyles="\n    #blookScriptGUI {\n        position: fixed;\n        top: 50px;\n        left: 50px;\n        z-index: 9999;\n        background-color: white;\n        border: 1px solid #ccc;\n        border-radius: 5px;\n        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n        cursor: move;\n        user-select: none;\n    }\n    #blookScriptHeader {\n        padding: 10px;\n        background-color: #007bff;\n        color: white;\n        border-top-left-radius: 5px;\n        border-top-right-radius: 5px;\n    }\n    #blookScriptContent {\n        padding: 20px;\n    }\n",styleElement=document.createElement("style");styleElement.textContent=guiStyles,document.head.appendChild(styleElement),document.body.appendChild(blookScriptGUI);let initialX,initialY,isDragging=!1;const guiElement=document.getElementById("blookScriptGUI");guiElement.addEventListener("mousedown",(function(t){isDragging=!0,initialX=t.clientX-guiElement.offsetLeft,initialY=t.clientY-guiElement.offsetTop})),document.addEventListener("mousemove",(function(t){if(isDragging){const e=t.clientX-initialX,n=t.clientY-initialY;guiElement.style.left=`${e}px`,guiElement.style.top=`${n}px`}})),document.addEventListener("mouseup",(function(){isDragging=!1})),document.querySelector("#ch").addEventListener("click",(t=>{runcheat()})),document.querySelector("#options").innerHTML="",getCheats().then((t=>{t.forEach((t=>{var e=document.createElement("option");e.value=t.path,e.innerText=t.name,document.querySelector("#options").appendChild(e)}))}));